/**
 * Created with IntelliJ IDEA.
 * Description:验证回文字符串2
 * User: wangxin
 * Date: 2025-02-04
 * Time: 20:01
 */
public class Test1 {
    public boolean validPalindrome(String s) {
        char[] ch = s.toCharArray();
        int left = 0,right = s.length()-1;
        boolean f = true;
        while(left < right){
            if(ch[left] == ch[right]){
                left++;
                right--;
            }else{
                return validPalindromeChild(ch,left+1,right)||validPalindromeChild(ch,left,right-1);
            }
        }
        return true;
    }
    public boolean validPalindromeChild(char[] ch,int left,int right){
        while(left < right){
            if(ch[left] != ch[right]){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
